﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
namespace CMS.Class
{
    public class clsInsert
    {
        public clsInsert()
        {
            //
            // TODO: Add constructor logic here
            //

        }

        private static String _strQpWeb = Constant.Connec;


        public static void InsertCongNo(int NAM, int THANG, String strMATK, String strMAKH, Boolean isKH, Boolean isNCC)
        {

            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_CongNo_AddNew", new SqlParameter("@NAM", NAM), new SqlParameter("@THANG", THANG),
                new SqlParameter("@MATK", strMATK), new SqlParameter("@MAKH", strMAKH),
                new SqlParameter("@isKH", isKH), new SqlParameter("@isNCC", isNCC));

        }

        public static void InsertVTHH(String strMAVTHH, String strTENVTHH, String strMAKHO, int NAM, int THANG, Boolean is_NLV, Boolean is_SP, int QUAYID)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_VTHH_AddNew", new SqlParameter("@NAM", NAM),
                new SqlParameter("@THANG", THANG),
                new SqlParameter("@MAVTHH", strMAVTHH), new SqlParameter("@TENVTHH", strTENVTHH),
                new SqlParameter("@MAKHO", strMAKHO),
                new SqlParameter("@is_NVL", is_NLV), new SqlParameter("@is_SP", is_SP),
                new SqlParameter("@QUAYID", QUAYID));
        }

        public static void Insert(DataTable m_Tb, String tableName)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.Ghi(tableName, m_Tb);
        }

        public static void UpdateConfig(String strName, String value)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_UpdateConfig", new SqlParameter("@NAME", strName),
                new SqlParameter("@VALUE", value));

        }

        public static void UpdateisPhoToShop(String strLOAICT, String strSOCT, Boolean isPhoToShop, int NAM, int THANG)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_UpDatePhotoShop", new SqlParameter("@LOAICT", strLOAICT),
                new SqlParameter("@SOCT", strSOCT), new SqlParameter("@isPhoToShop", isPhoToShop),
                new SqlParameter("@NAM", NAM), new SqlParameter("@THANG", THANG));

        }

        public static void UpdateisIn(String strLOAICT, String strSOCT, Boolean isIn, int NAM, int THANG)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_UpDateIn", new SqlParameter("@LOAICT", strLOAICT),
                new SqlParameter("@SOCT", strSOCT), new SqlParameter("@isIn", isIn),
                new SqlParameter("@NAM", NAM), new SqlParameter("@THANG", THANG));

        }

        public static void UpdateisCheck(String strLOAICT, String strSOCT, Boolean isCheck, int NAM, int THANG)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_UpDateisCheck", new SqlParameter("@LOAICT", strLOAICT),
                new SqlParameter("@SOCT", strSOCT), new SqlParameter("@isCheck", isCheck),
                new SqlParameter("@NAM", NAM), new SqlParameter("@THANG", THANG));

        }

        public static void UpdateisGiaoAnhQuay(String strLOAICT, String strSOCT, Boolean isGiaoAnhQuay, int NAM, int THANG)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_UpDateisGiaoAnhQuay", new SqlParameter("@LOAICT", strLOAICT),
                new SqlParameter("@SOCT", strSOCT), new SqlParameter("@isGiaoAnhQuay", isGiaoAnhQuay),
                new SqlParameter("@NAM", NAM), new SqlParameter("@THANG", THANG));

        }

        public static void UpdateisTraKhach(String strLOAICT, String strSOCT, Boolean isTraKhach, int NAM, int THANG)
        {
            QpWebConnec.QpConnec connec = null;
            connec = new QpWebConnec.QpConnec(_strQpWeb);
            connec.ExecuteNonQuery("p_UpDateisGiaoKhachHang", new SqlParameter("@LOAICT", strLOAICT),
                new SqlParameter("@SOCT", strSOCT), new SqlParameter("@isTraKhach", isTraKhach),
                new SqlParameter("@NAM", NAM), new SqlParameter("@THANG", THANG));

        }

        public static void XuatNhapTon(int Nam, int Thang)
        {
            QpWebConnec.QpConnec cls = new QpWebConnec.QpConnec(_strQpWeb);

            //Cap nhap xuat kho
            cls.ExecuteNonQuery("p_UpdateXuat", new SqlParameter("@NAM", Nam),
                new SqlParameter("@THANG", Thang));

            //cap nhat nhap kho
            cls.ExecuteNonQuery("p_UpdateNhapKho", new SqlParameter("@NAM", Nam),
                            new SqlParameter("@THANG", Thang));

            //Tin tien nhap kho san pham va nguyen vat lieu
            cls.ExecuteNonQuery("p_TinhTienNhapKho", new SqlParameter("@NAM", Nam),
                            new SqlParameter("@THANG", Thang));

            //p_GiaXuatKho
            //Tinh gia xuat kho 

            cls.ExecuteNonQuery("p_GiaXuatKho", new SqlParameter("@NAM", Nam),
                            new SqlParameter("@THANG", Thang));

        }

        public static void UpDateDauKyKho(decimal TONDK, decimal dongia, decimal ROWID)
        {
            //p_UpdateDauKyKho`i87u[ppp[=-         QpWebConnec.QpConnec cls = new QpWebConnec.QpConnec(_strQpWeb);
            //cls.ExecuteNonQuery("p_UpdateDauKyKho", new SqlParameter("@TONDK", TONDK),
            //             new SqlParameter("@VNDDGXUAT", dongia), new SqlParameter("@ROWID", ROWID));
        }

        public static void UpdatePhanQuyen(int view, int add, int edit, int del, int show, String rowid)
        {
            QpWebConnec.QpConnec cls = new QpWebConnec.QpConnec(_strQpWeb);
            cls.ExecuteNonQuery("p_UpdatePhanQuyen", new SqlParameter("@VIEW", view), new SqlParameter("@ADD", add),
                           new SqlParameter("@DEL", del), new SqlParameter("@EDIT", edit),
                           new SqlParameter("@SHOW", show), new SqlParameter("@ROWID", rowid));

        }
    }
}